import { http } from '@/utils/http/axios';

export interface Category {
  categoryId: number;
  categoryName: string;
  state: number;
  key: string;
  parentId: number;
  ranking: number;
}

export function getCategory() {
  return http.request({
    url: '/category/getCategory',
    method: 'get',
  });
}

export function addCategory(params) {
  return http.request({
    url: '/category',
    method: 'POST',
    params: params,
  });
}

export function deleteCategoryById(id) {
  return http.request({
    url: `/category/${id}`,
    method: 'delete',
  });
}

export function updateCategory(id, name) {
  const category = {
    id,
    name,
  };
  return http.request({
    url: '/category',
    method: 'put',
    params: category,
  });
}
